package com.Thread;

import com.sun.xml.internal.ws.policy.privateutil.PolicyUtils;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86184
 * Date: 2023-12-21
 * Time: 11:09
 */
//public class TestDemo1 {
//    public static void main(String[] args) {
//        //创建一个线程对象
//        MyThread t = new MyThread();
//        //启动线程
//        t.start();
//    }
//}
//
//class MyThread extends Thread{
//    public void run(){
//        for (int i = 1; i <= 1000; i++) {
//            System.out.println("hello "+i);
//        }
//    }
//
//}

//public class TestDemo1 {
//    public static void main(String[] args) {
//        //创建Thread对象，需要传入实现的对象的引用
//        Thread t = new Thread(new MyThread());
//        //启动线程
//        t.start();
//    }
//}
//
//class MyThread implements Runnable{
//    public void run(){
//        for (int i = 0; i < 1000; i++) {
//            System.out.println("hello "+i);
//        }
//    }
//}

//public class TestDemo1 {
//    public static void main(String[] args) {
//
//    }
//}
//
//class MyThread extends Thread{
//    public void run(){
//        for (int i = 1; i <= 1000; i++) {
//            System.out.println("hello Java" +i);
//        }
//    }
//}

public class TestDemo1 {
    public static void main(String[] args) {
        FileInputStream in = null;
        FileOutputStream out = null;

        try{
            in = new FileInputStream("c:\\Javacode2\\b.txt");
            out = new FileOutputStream("c:\\Javacode2\\b-copy.txt");

            int i;
            while((i = in.read()) != -1){
                out.write(i);
            }
        }catch(IOException e){
            e.printStackTrace();
        }finally {
            if(in != null){
                try{
                    in.close();
                }catch(IOException e){
                    e.printStackTrace();
                }finally {
                    in = null;
                }
            }

            if(out != null){
                try{
                    out.close();
                }catch(IOException e){
                    e.printStackTrace();
                }finally {
                    out = null;
                }
            }
        }


    }
}